<template>
    <div class="clearfix" id="login_wrap">
        <el-form ref="form" :model="form" label-width="80px">
  <el-form-item label="账号">
    <el-input v-model="form.sysUserName"></el-input>
  </el-form-item>
  <el-form-item label="密码">
    <el-input v-model="form.sysUserPsw"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary"  @click="onSubmit">立即创建</el-button>
    <el-button>取消</el-button>
  </el-form-item>
</el-form>
    </div>
</template>

<script >
import { defineComponent,btnPermissions,foucus } from 'vue'
import {loginApi} from "@/api/login";
import { useRouter } from 'vue-router';
import {useStore} from "vuex";
export default {
    data() {
      return {
        form: {
            sysUserName: '',
            sysUserPsw: '',
         
        }
      }
    },
    methods: {
      onSubmit() {
       
      
       loginApi(this.form).then(req =>{
        if(req.code== 200 ){
          console.log(`req.data`,req.data.btnPre );
        this.$store.commit("SET_TOKEN",req.data.token)      
        this.$store.commit("SET_USERINFO",req.data.sysUsers)
        this.$store.commit("SET_PERMISSION",null); 
        this.$store.commit("SET_PERMISSIONLIST",req.data.permissionlist); 
        this.$store.commit("SET_BTNPRE",req.data.btnPre); 
        
        this.$router.push({path:"/"});
        }
              //  localStorage.setItem("ms_username", this.ruleForm.username);// 使用localstoage来记录登陆信息
              //   localStorage.setItem("roles", successResponse.data.loginInfo.roleList);
              //   localStorage.setItem("permissions", successResponse.data.loginInfo.permissionList);
         
          
      
      
       })
      }
    },
  
  }

</script>

